#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct zone
{
	int start;
	int end;
}Z;
int main()
{
	int l = 0;
	int m = 0;
	scanf("%d%d", &l, &m);
	Z* p = (Z*)malloc(m * sizeof(*p));
	int i = 0;
	for (i = 0; i < m; i++)
	{
		scanf("%d%d", &(p + i)->start, &(p + i)->end);
	}
	int* pl = (int*)malloc((l + 1) * sizeof(int));
	memset(pl, 0, 4 * l + 4);
	for (i = 0; i < m; i++)
	{
		int j = 0;
		for (j = (p + i)->start; j <= (p + i)->end; j++)
		{
			pl[j] = 1;
		}
	}
	int sum = 0;
	for (i = 0; i <= l; i++)
	{
		sum += pl[i];
	}
	printf("%d", l - sum + 1);
	return 0;
}
